import { computed } from 'vue';
<template>
    <div class="layout">
        <Layout>
            <Sider ref="side1" hide-trigger collapsible :collapsed-width="78" v-model="isCollapsed">
                <Menu theme="dark" width="auto" class="menuitemClasses" active-name="2-1">
                    <MenuItem name="1">
                    <Icon type="ios-navigate"></Icon>
                    <span>首页</span>
                    </MenuItem>
                    <Submenu to="/home/educationMange/baseMaintain" name="2">
                        <template #title>
                            <Icon type="ios-navigate"></Icon>
                            教育管理
                        </template>
                        <MenuItem name="2-1" to="/home/educationMange/baseMaintain">基础信息维护</MenuItem>
                        <MenuItem name="2-2" to="/home/educationMange/teacherManage">教师管理</MenuItem>
                        <MenuItem name="2-3" to="/home/educationMange/studentManage">学生管理</MenuItem>
                        <MenuItem name="2-4" to="/home/educationMange/classManage">班级管理</MenuItem>
                        <MenuItem name="2-5" to="/home/educationMange/GradeMaintenance">年级主任维护</MenuItem>
                        <MenuItem name="2-6" to="/home/educationMange/courseManage">排课管理</MenuItem>
                    </Submenu>
                    <Submenu to="/home/shiftChange/courseSelection" name="3">
                        <template #title>
                            <Icon type="ios-navigate"></Icon>
                            走班排课
                        </template>
                        <MenuItem name="3-1" to="/home/shiftChange/courseSelection">选课设置</MenuItem>
                        <MenuItem name="3-2" to="/home/shiftChange/classAllocation">智能分班</MenuItem>
                        <MenuItem name="3-3" to="/home/shiftChange/shiftChangeItem">走班排课</MenuItem>
                    </Submenu>
                    <Submenu to="/home/prepareLessons/PersonalLesson" name="4">
                        <template #title>
                            <Icon type="ios-navigate"></Icon>
                            备课管理
                        </template>
                        <MenuItem name="4-1" to="/home/prepareLessons/PersonalLesson">个人备课</MenuItem>
                        <MenuItem name="4-2" to="/home/prepareLessons/lessonGroupManagement">备课组管理</MenuItem>
                        <MenuItem name="4-3" to="/home/prepareLessons/lessonExample">备课示例</MenuItem>
                    </Submenu>
                    <Submenu to="/home/jobManagement/jobManageaItem" name="5">
                        <template #title>
                            <Icon type="ios-navigate"></Icon>
                            作业管理
                        </template>
                        <MenuItem name="5-1" to="/home/jobManagement/jobManageaItem">作业管理</MenuItem>
                        <MenuItem name="5-2" to="/home/jobManagement/jobStatistics">作业统计</MenuItem>
                    </Submenu>
                    <Submenu to="/home/resourceManagement/interTranscripts" name="6">
                        <template #title>
                            <Icon type="ios-navigate"></Icon>
                            资源管理
                        </template>
                        <MenuItem name="6-1" to="/home/resourceManagement/interTranscripts">教学资源管理</MenuItem>
                        <MenuItem name="6-2" to="/home/resourceManagement/extraResources">课外资源管理</MenuItem>
                        <MenuItem name="6-3" to="/home/resourceManagement/TypeManagement">资源类型管理</MenuItem>
                    </Submenu>
                    <Submenu to="/home/configuration/academicYear" name="7">
                        <template #title>
                            <Icon type="ios-navigate"></Icon>
                            配置管理
                        </template>
                        <MenuItem name="7-1" to="/home/configuration/academicYear">学年学科配置</MenuItem>
                        <MenuItem name="7-2" to="/home/configuration/academicTerm">学年学期配置</MenuItem>
                        <MenuItem name="7-3" to="/home/configuration/textbook">教材管理配置</MenuItem>
                        <MenuItem name="7-4" to="/home/configuration/textTemplate">教案模板配置</MenuItem>
                    </Submenu>
                </Menu>
            </Sider>
            <Layout>
                <Header :style="{ padding: 0 }" class="layout-header-bar">
                    <div class="title_box">
                        <Icon @click="collapsedSider" class="rotateIcon" :style="{ margin: '12px 20px' }" type="md-menu"
                            size="24" ref="dom"></Icon>
                        <h1>学校管理系统</h1>
                    </div>
                    <div>
                        <Dropdown>
                            <a href="javascript:void(0)">
                                lisa
                                <Icon type="ios-arrow-down"></Icon>
                            </a>
                            <template #list>
                                <DropdownMenu>
                                    <DropdownItem>退出登录</DropdownItem>
                                </DropdownMenu>
                            </template>
                        </Dropdown>
                    </div>
                </Header>
                <Content :style="{ margin: '20px', background: '#fff', minHeight: '260px' }">
                    <router-view></router-view>
                </Content>
            </Layout>
        </Layout>
    </div>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue'
const isCollapsed = ref(false)
let side1 = ref<any>(null)
computed(() => {
    const rotateIcon = () => {
        return [
            'menu-icon',
            isCollapsed.value ? 'rotate-icon' : ''
        ];
    }
    const menuitemClasses = () => {
        return [
            'menu-item',
            isCollapsed.value ? 'collapsed-menu' : ''
        ]
    }
    return { rotateIcon, menuitemClasses }
})
const collapsedSider = () => {
    side1.value?.toggleCollapse();
}
</script>
<style scoped>
.layout {
    border: 1px solid #d7dde4;
    background: #f5f7f9;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
}

.layout .ivu-menu {
    z-index: 0
}

.title_box {
    display: flex;
    width: 200px;
    height: 54px;
    line-height: 54px;

    i {
        margin-right: 10px;
    }

    h1 {
        font-size: 20px;
    }
}

>>>.ivu-layout-header {
    height: 54px;
    line-height: 54px;
}

.layout-header-bar {
    background: #fff;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .1);
    display: flex;
    justify-content: space-between;
}

.layout-logo-left {
    width: 90%;
    height: 30px;
    background: #5b6270;
    border-radius: 3px;
    margin: 15px auto;
}

.menu-icon {
    transition: all .3s;
}

.rotate-icon {
    transform: rotate(-90deg);
}

.menu-item span {
    display: inline-block;
    overflow: hidden;
    width: 69px;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    transition: width .2s ease .2s;
}

.menu-item i {
    transform: translateX(0px);
    transition: font-size .2s ease, transform .2s ease;
    vertical-align: middle;
    font-size: 16px;
}

.collapsed-menu span {
    width: 0px;
    transition: width .2s ease;
}

.collapsed-menu i {
    transform: translateX(5px);
    transition: font-size .2s ease .2s, transform .2s ease .2s;
    vertical-align: middle;
    font-size: 22px;
}
</style>